package fr.utbm.lo53;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class OnActivity extends Activity implements OnClickListener {
    /** Called when the activity is first created. */
    Button btnMeasure ; 
    EditText posX ;
    EditText posY ;
    EditText mid ;
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.offactivity);
        btnMeasure = (Button)findViewById(R.id.measure);
        btnMeasure.setText("Locate");
        btnMeasure.setOnClickListener(this);
        posX = (EditText)findViewById(R.id.posX);
        posY = (EditText)findViewById(R.id.posY);
        mid = (EditText)findViewById(R.id.mid);
    }
    public boolean onCreateOptionsMenu(Menu menu)
    {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.main_menu, menu);
        return true;
    }
    public boolean onOptionsItemSelected(MenuItem item)
    {
    	int id = item.getItemId();
        // Handle item selection
        switch (id)
        {
        case R.id.settings:
        	Intent settingsActivity = new Intent(getBaseContext(), SettingsActivity.class);
        	startActivity(settingsActivity);
            return true;
        default:
            return super.onOptionsItemSelected(item);
        }
    }
	public void onClick(View v) {
		if (v == btnMeasure) {
			Network.getInstance().startMeasure();
			//TODO: add the request tomcat & answer
			/*
			 HttpResponse response=httpclient.execute(httppost);
			 BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
			 String s = reader.readLine();
			 */
		}
	}
}